<template>
    <el-table
      :data="tableData"
      border
      style="width: 90%; margin: 20px auto;border-radius: 8px; margin: 20px auto;box-shadow: 5px 5px 10px rgba(64, 158, 255, 0.5);"
      :header-cell-style="{
          'background': '#337ecc !important',
          'color': '#ffffff',
          'border': 'none !important'
        }">
		
		<el-table-column prop="fileName" label="文件名" width=""></el-table-column>
		<el-table-column prop="reward" label="特殊绩效/￥" width=""></el-table-column>
	
    </el-table>
	<div style="text-align: right;margin-right: 200px;margin-bottom: 20px;"> 总计：{{total}}￥</div>
	
</template>

<script setup>
import {ref, onBeforeMount, reactive,getCurrentInstance,watch} from "vue";


let props = defineProps({
  rewardList: {
    type: Array,
    required: true, //是否规定必须得有
  }
})


var total = 0;
for(var i = 0;i<props.rewardList.length;i++){
	  total += parseFloat(props.rewardList[i].reward)
}
total = total.toFixed(2)


watch(props, (newValue, oldValue) => {
  // total = 0
  tableData.value=newValue.rewardList
  total = 0;
  for(var i = 0;i<props.rewardList.length;i++){
  	  total += parseFloat(props.rewardList[i].reward)
  }
  total = total.toFixed(2)
},{ deep: true });  

const tableData=ref(props.rewardList)



</script>



<style lang="scss" scoped>

.formWrapper{
    width: 100%;
    border: 2px solid #DCDFE6;
    margin: 20px 0;
    border-radius: 5px;
    .formTitle{
        height: 50px;
        font-weight: bold;
        color: #303133;
        font-size: 25px;
        text-align: center;
        line-height: 50px;
        border-bottom: #DCDFE6 1px solid;
    }

    .form{
        width: 1200px;
        margin: 20px auto;
        border-radius: 5px;
        .title {
            display: flex;
            flex-wrap: wrap;
            justify-content: flex-start;/* 替代space-between布局方式 */
            .title_box{
                width: 200px;
                flex: 1;
                height: 50px;
                background-color: #337ECC;
                text-align: center;
                color: #fff;
                line-height: 50px;
                font-size: 20px;
            }
        }
        .centent {
            display: flex;
            flex-wrap: wrap;
            justify-content: flex-start;/* 替代space-between布局方式 */
            .centent_box{
                width: 200px;
                flex: 1;
                height: 50px;
                background-color: #79bbff;
                color: #fff;
                padding: 5px;
                line-height: 40px;
                text-align: center;
            }
        }
    }
    .button{
        width: 200px;
        height: 40px;
        margin: 10px auto;
        float: right;
    }
}
</style>
